#读取站台数量
length = int(input())

#读取站台之间的距离
nums = input().split()
nums = [int(num) for num in nums]

#读取出发低、目的地
data = input()
start,end = int(data.split()[0]),int(data.split()[1])

#如果start>end,直接计算即可
#如果start<end,则计算sum-(end->start)


if start < end:
    total_distance = sum(nums[start-1:end-1]) 
else:
    total_distance = sum(nums[end-1:start-1]) 
    
print(total_distance)
        